//half pixels are GREAT - well, they seem to work here
#define CHOICE_Y(i) ( 15.0889 + ( i * 20 ) ) //this is y-axis position
#define CHOICE_ORIGIN(i) -98.6667 CHOICE_Y(i) //this is the x-axis position
#define CHOICE_RECT(i) CHOICE_ORIGIN(i) 336 17.3333 1 1 //this contains the material size/ alignment //336 20 1 1
		
#define CHOICE_RECT1(i) -98.6667 ( 15.0889 +( i * 20 ) ) 336 17.3333 1 1

#define HR_ORIGIN(i) 0 ( CHOICE_Y(i) - 0.5 )
#define HR_RECT(i) HR_ORIGIN(i) 216 1 1 1

#define SHADOW_ORIGIN(i) -98.6667 ( CHOICE_Y(i) + 17.333) //this is the x-axis position then y-axis
#define SHADOW_RECT(i) SHADOW_ORIGIN(i) 336 3.6667 1 1 //this contains the material size/alignment

		#define CLOSE_MENUS \
				close "pc_options_video"; \
				close "pc_options_voice"; \
				close "pc_options_adanced_video"; \
				close "options_texture_quality"; \
				close "pc_options_audio"; \
				close "pc_options_movement"; \
				close "pc_options_controls"; \
				close "options_look"; \
				close "options_move"; \
				close "options_shoot"; \
				close "options_misc"; \
				close "options_graphics"; \
				close "options_sound"; \
				close "options_game"; \
				close "options_view"; \
				close "options_defaults"; \
				close "options_driverinfo"; \
				close "options_credits"; \
				close "options_multi"; \
				close "options_graphics_defaults"; \
				close "options_graphics_texture"; \
				close "options_control_defaults"; \
				close "options_voice"; \
				close "options_multi"; \
				close "controls_multi"; \
				close "main_options"; \
				close "pc_options_audio"; \
				close "pc_options_video"; \
				close "main_controls"; \
				
		#define APPLY_CHANGES \
			    if ( !( menuisopen( "pc_options_advanced_video" ) || menuisopen( "pc_options_video" ) || menuisopen( "pc_options_Audio" ) || menuisopen( "pc_options_controls" ) || menuisopen( "pc_options_voice" ) ) && localvarbool( "ui_showPicApply" ) && !localvarbool( "ui_showApply" ) && !localvarbool( "ui_showAudioApply" )  )  \
			    { \
			    	execNow "setfromdvar r_picmip ui_r_picmip"; \
			    	execNow "setfromdvar r_picmip_bump ui_r_picmip_bump"; \
			    	execNow "setfromdvar r_picmip_spec ui_r_picmip_spec"; \
			    	execNow "setfromdvar r_picmip_manual ui_r_picmip_manual"; \
			    	exec "wait; wait; r_applyPicmip"; \
			    	setLocalVarBool ui_showPicApply 1; \
		    	} \
		    	if ( !( menuisopen( "pc_options_advanced_video" ) || menuisopen( "pc_options_video" ) || menuisopen( "pc_options_Audio" ) || menuisopen( "pc_options_controls" ) || menuisopen( "pc_options_voice" ) ) && localvarbool( "ui_showApply" ) || localvarbool( "ui_showAudioApply" )  ) \
			    { \
			    	open all_restart_popmenu; \
		        } \
		        ExecNow "profile_menuDvarsFinish; resetViewport"; \
            }
#define IW5_TITLE_VIS( textArg, visArg ) \
		itemDef \
		{ \
			rect 0 0 272 28 1 1 \
			foreColor 1 1 1 1 \
			decoration \
			textAlign 6 \
			textAlignX -60 \
			textScale 0.5 \
			textFont 9 \
			text textArg \
			visible visArg \
		}
#define IW5_SECTION_TITLE_VIS( textArg, visArg ) \
		itemDef \
		{ \
			rect 232 0 80 28 1 1 \
			foreColor 1 1 1 1 \
			decoration \
			textAlign 6 \
			textScale 0.5 \
			textFont 9 \
			text textArg  \
			visible 1  \
		}
#define IW5_BUTTON_VIS( itemIndex, textArg, actionArg, visArg) \
		itemDef \
		{ \
			rect CHOICE_RECT(itemIndex) \
			foreColor 1 1 1 1 \
			style 1 \
			background gradient_fadein \
			group mw2_button \
			type 1 \
			textAlign 6 \
			textAlignY -1 \
			textAlignX -25.6667 \
			textScale 0.375 \
			textFont 3 \
			text textArg \
			onFocus \
            { \
				play mouse_over; \
				setItemColor self backcolor 0.488 0.520 0.465 1; \
				setLocalVarInt ui_highlight ( itemIndex ); \
            } \
            leaveFocus \
            { \
				setItemColor self backcolor 0 0 0 0.0; \
				setLocalVarInt ui_highlight ( 0 ); \
            } \
            action \
            { \
				play mouse_click; \
				actionArg \
            } \
			visible visArg \
		} \
		itemDef \
		{ \
				style 3 \
				rect SHADOW_RECT(itemIndex) \
				forecolor 1 1 1 1 \
				exp material("gradient_top"); \
				border 0 \
				bordersize 0 \
				bordercolor 0 0 0 0 \
				visible when( localVarInt( ui_highlight ) == itemIndex ); \
				decoration \
		}		
#define IW5_SEPERATOR(itemIndex) \
	itemDef \
		{ \
			rect HR_RECT(itemIndex) \
			style 3 \
			foreColor 1 1 1 0.65 \
			background gradient_fadein \
			decoration \
			textScale 0.55 \
			visible 1 \
		}
#define IW5_ESC_BUTTON(visArg) \
		itemDef \
		{ \
			name  "backbutton" \
			rect 550 420 60 17.5 \
			border 0 \
			foreColor 1 1 1 1 \
			backColor 0 0 0 0 \
			style 1 \
			type 1 \
			textAlign 5 \
			textAlignX 0 \
			textAlignY -1 \
			textScale 0.375 \
			textFont 3 \
			text "Back ^2ESC" \
			visible 1 \
			onFocus \
			{ \
				play mouse_over; \
				setItemColor self "backcolor" 1 1 1 0.5; \
				setLocalVarBool ui_menuAButton 1; \
			} \
			leaveFocus \
			{ \
				setItemColor self "backcolor" 0 0 0 0; \
				setLocalVarBool ui_menuAButton 0; \
			} \
			action \
			{ \
				play "mouse_click"; \
				play "mouse_click"; \
				escape "self"; \
				APPLY_CHANGES \
			} \
		}
#define IW5_NEW_VIS( itemIndex, visArg ) \
		itemDef \
		{ \
			rect CHOICE_RECT(itemIndex) \
			style 1 \
			foreColor 1 0.8 0.4 1 \
			decoration  \
			textScale 0.375	 \
			text "NEW" \
			textAlign 6 \
			textAlignY -1 \
			textAlignX -65 \
			visible visArg \
		}			